package com.zpark.test;

import com.zpark.beans.*;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @PackageName: com.zpark.test
 * @ClassName: Client
 * @Description:
 * @author: RZS
 * @date: 2023/3/27  14:55
 */
public class Client {

    // 定义Spring容器对象
    private ApplicationContext app = new ClassPathXmlApplicationContext("application.xml");

    @Test
    public void test1(){
        // 创建User对象
        // User user = new User("DC", "123456");

        // 根据id获取bean
        User user = app.getBean("user", User.class);
        System.out.println(user);
    }

    @Test
    public void test2(){

        // 根据id获取bean
        Emp emp = app.getBean("emp", Emp.class);
        System.out.println(emp);
    }

    @Test
    public void test3(){

        // 根据id获取bean
        Empty empty = app.getBean("empty", Empty.class);
        System.out.println(empty);
    }

    @Test
    public void test4(){

        // 根据id获取bean
        Dept dept = app.getBean("dept", Dept.class);
        System.out.println(dept);
    }

    @Test
    public void test5(){

        // 根据id获取bean
        MyObj myObj = app.getBean("myObj", MyObj.class);
        System.out.println(myObj);
    }
}
